package com.qc.AirQuality.web;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.qc.AirQuality.dao.AirQualityIndexDao;

public class AirQualityIndexSrevlet extends HttpServlet {

	private static final long serialVersionUID = -7295145508371090891L;


	public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {

		this.doPost(request, response);

	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {

		String str = request.getParameter("distId");
		Integer distId = null;
		if(str != null){
			distId = Integer.valueOf(str);
		}
		
		str = request.getParameter("pageIndex");
		if(str == null){
			str = "1";
		}
		
		Integer pageIndex = Integer.valueOf(str);
		Integer pageSize = 2;
		
		AirQualityIndexDao dao = new AirQualityIndexDao();
		List<Map<String,Object>> list = dao.findAll1(distId, pageIndex, pageSize);
		
		request.setAttribute("list", list);
		request.setAttribute("pageIndex", pageIndex);
		request.setAttribute("distId", distId);
		
		request.getRequestDispatcher("index.jsp").forward(request, response);
	
	}

}








